package com.rz.admin.controller;

import com.rz.admin.entity.Role;
import com.rz.admin.entity.vo.DeleteParam;
import com.rz.admin.entity.vo.RoleResReq;
import com.rz.admin.service.IRoleService;
import com.rz.core.kit.RespKit;
import com.rz.core.resp.ResultResp;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("role")
public class RoleCtrl {

    @Resource private IRoleService roleService;

    @PostMapping("page")
    public ResultResp getPage(@RequestBody Role role){
        return RespKit.success(roleService.getPage(role));
    }

    @PostMapping("delete")
    public ResultResp delete(@RequestBody DeleteParam deleteParam){
        return RespKit.success(roleService.batchDelete(deleteParam));
    }

    @PostMapping("saveRoleRes")
    public ResultResp saveRoleRes(@RequestBody Role role){
        return RespKit.success(roleService.saveRoleRes(role));
    }

    @PostMapping("getResByRoleId/{roleId}")
    public ResultResp getResByRoleId(@PathVariable Integer roleId){
        return RespKit.success(roleService.getResByRoleId(roleId));
    }
}
